package alitaV.servlet;
/**
this servlet is use for login
 **/
import alitaV.JdbcUtils;
import alitaV.old.user;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class LoginServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=utf-8");
        String username = req.getParameter("u");
        String password = req.getParameter("p");
        String confirm = req.getParameter("c");
        System.out.println(username+password);
        PrintWriter writer = resp.getWriter();
        String sql = "SELECT id FROM `user` WHERE username=? && password=md5(?)";
        user user = JdbcUtils.select(sql, user.class,username,password);
        if(user!=null){
            writer.write("登陆成功1");
        }
        else
            writer.write("登录页面");
        writer.flush();
        writer.close();
    }
}
